package gazzera.swing.shares;

import gazzera.swing.model.*;
import gazzera.utils.*;

import java.util.*;

import javax.swing.table.*;


public class ShareListModel extends AbstractTableModel
{
	private List<Share> list;
	

	public ShareListModel(List<Share> list)
	{
		super();
		this.list = list;
	}

	@Override
	public int getColumnCount()
	{
		return 3;
	}

	@Override
	public int getRowCount()
	{
		return list.size();
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex)
	{
		Share c = list.get(rowIndex);
		switch (columnIndex)
		{
		case 0:
			return c.id;
		case 1:
			return c.folder;
		case 2:
			String s = Str.join(c.groups, ",");
			if (Str.isEmpty(s)) s = "Everybody";
			return s;

		default:
			break;
		}
		return c;
	}
	
	
	
}